package com.honghu.villagepost.adapter

import androidx.recyclerview.widget.RecyclerView
import com.honghu.villagepost.R
import com.honghu.villagepost.entity.OrderDetails
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder

/**
 * @author: mqwang
 * @create: 2/22/21 9:57 AM
 * @Description:
 */
public class OrderAdapter : BaseQuickAdapter<OrderDetails, BaseViewHolder>(R.layout.adapter_order) {
    override fun convert(helper: BaseViewHolder?, item: OrderDetails?) {
        helper!!.setText(R.id.tv_store_name, item!!.shopName)
        helper!!.setText(R.id.tv_total, mContext.getString(R.string.price_format, item!!.totalFee))

        val recyclerView = helper.getView<RecyclerView>(R.id.recycler_view)
        val orderGoodsAdapter = OrderGoodsAdapter();
        recyclerView.adapter = orderGoodsAdapter

        orderGoodsAdapter.setNewData(item.orderItemList)

        helper.addOnClickListener(R.id.tv_status)

        when(item!!.state){
            //等待买家付款
            1->{
                helper.setText(R.id.tv_status, "去支付")
            }
            //2-买家已付款, 3-等待卖家发货,即:买家已付款, 4-卖家发货中, 5-卖家部分发货, 6-等待买家确认收货,即:卖家已发货
            2,3,4,5,6->{
                helper.setText(R.id.tv_status, "配送中")
            }

            //10-交易成功,即ø:卖家已发货,11-交易成功,即:卖家已发货,12-交易被系统关闭
            10, 11, 12->{
                helper.setText(R.id.tv_status, "已完成")
            }
        }
    }
}